package response

import "mallgo/internal/resources/product/model"

type ProductResponse struct {
	ID       int64   `json:"id"`
	Name     string  `json:"name"`
	Note     string  `json:"note"`
	Logo     string  `json:"logo"`
	Price    float64 `json:"price"`
	Discount float64 `json:"discount"`
	AddDate  string  `json:"add_date"`
	LastDate string  `json:"last_date"`
}

type ProductSimple struct {
	ID       int64   `json:"id"`
	Name     string  `json:"name"`
	Note     string  `json:"note"`
	Logo     string  `json:"logo"`
	Price    float64 `json:"price"`
	Discount float64 `json:"discount"`
	AddDate  string  `json:"add_date"`
	LastDate string  `json:"last_date"`
}

func ConvertSimple(product *model.Product) ProductSimple {
	return ProductSimple{
		ID:       product.ID,
		Name:     *product.Name,
		Note:     *product.Note,
		Logo:     *product.Logo,
		Price:    *product.Price,
		Discount: *product.Discount,
		AddDate:  product.AddDate.Format("2006-01-02 15:04:05"),
		LastDate: product.LastDate.Format("2006-01-02 15:04:05"),
	}
}

func ConvertResponse(product *model.Product) ProductResponse {
	return ProductResponse{
		ID:       product.ID,
		Name:     *product.Name,
		Note:     *product.Note,
		Logo:     *product.Logo,
		Price:    *product.Price,
		Discount: *product.Discount,
		AddDate:  product.AddDate.Format("2006-01-02 15:04:05"),
		LastDate: product.LastDate.Format("2006-01-02 15:04:05"),
	}
}
